Modelling_plots
Southern BC Spring and Fall fisheries
- The best model was one with a gamma distribution
- Next, we investigated if the fully interactive model is better than a subset of interactions. We used the dredge function from the MuMin package to sequentially drop terms (including all interactions).
- The best model included summer creel, marked and kept status, finescale fishery, and season and various interactions of these terms
- \[ catch = creel.summer+finescale.fishery+season+status+ creel.summer:finescale.fishery + creel.summer:status+ finescale.fishery:season \]
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(Spring_fall_model)
ilink.family.set<- family.set$linkinv
mod<-Spring_fall_model
ndata<-Season_south_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(creel_plus_summer = seq(0, max(creel_plus_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))Show the code
yearMonth2_season <- plyr::ddply(Sport_mark_rate_finescale, c( "YEAR", "MONTH", "finescale_fishery", "season"), summarise,
sum_creel = sum(creel, na.rm = TRUE), sum= sum(creel_plus, na.rm = TRUE), sum_historic= sum(historic_plus, na.rm = TRUE), sum_catch_estimate = sum(catch_estimate, na.rm = TRUE), sum_irec = sum(irec_calibrated, na.rm = TRUE)) %>% filter(finescale_fishery!="NA") %>% mutate(across(where(is.numeric), ~na_if(., 0)))
yearMonth_catch_estimate_2_season<-yearMonth2_season %>% filter(sum_catch_estimate!=sum,sum_catch_estimate!=sum_historic, sum_catch_estimate!=sum_irec)
yearMonth_irec_2_season<-yearMonth2_season %>% filter(sum_catch_estimate==sum_irec)CA JDF S FALL
CA JDF S SPRING
JNST S FALL
JNST S SPRING
NGS S FALL
NGS S SPRING
NWCVI S FALL AABM
NWCVI S SPRING AABM
SGS S FALL
SGS S SPRING
SWCVI S FALL AABM
SWCVI S SPRING AABM
Southern BC Summer fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, finescale fishery, and various interactions of these terms
- \[ catch = creel.summer+finescale.fishery+status+ creel.summer:finescale.fishery + creel.summer:status \]
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(Summer_model)
ilink.family.set<- family.set$linkinv
mod<-Summer_model
ndata<-Summer_south_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(creel_plus_summer = seq(0, max(creel_plus_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))CA JDF S SUMMER
JNST S SUMMER
NGS S SUMMER
NWCVI S SUMMER AABM
NWCVI S SUMMER ISBM
SGS S SUMMER
SWCVI S SUMMER AABM
SWCVI S SUMMER ISBM
NBC AABM Spring and Fall fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, and season and various interactions of these terms
- \[ catch = creel.summer+season+status + creel.summer:season \]
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(North_aabm_model)
ilink.family.set<- family.set$linkinv
mod<-North_aabm_model
ndata<-Season_north_aabm_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(historic_summer = seq(0, max(historic_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))NBC AABM S FALL
NBC AABM S SPRING
NBC AABM Summer fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, and season and various interactions of these terms
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(Summer_north_aabm_model_gamma_spec)
ilink.family.set<- family.set$linkinv
mod<-Summer_north_aabm_model_gamma_spec
ndata<-Summer_north_aabm_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(historic_summer = seq(0, max(historic_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))NBC AABM S SUMMER
NBC ISBM Spring and Fall fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, and season and various interactions of these terms
- \[ catch = creel.summer+season+status + season:status \]
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(nbc_isbm_model_full_gamma_spec)
ilink.family.set<- family.set$linkinv
mod<-nbc_isbm_model_full_gamma_spec
ndata<-Season_north_isbm_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(historic_summer = seq(0, max(historic_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))NBC ISBM S FALL
NBC ISBM S SPRING
NBC ISBM Summer fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, and season and various interactions of these terms
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(Summer_north_isbm_model_full_gamma_spec)
ilink.family.set<- family.set$linkinv
mod<-Summer_north_isbm_model_full_gamma_spec
ndata<-Summer_north_isbm_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(historic_summer = seq(0, max(historic_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))NBC ISBM S SUMMER
CBC ISBM fisheries
- The best model was one with a gamma distribution
- The best model included summer creel, marked and kept status, and season and various interactions of these terms
- \[ catch = creel.summer+status \]
Show the code
#### Adding confidence intervals based on model to a dataframe for plotting purposes
#based on this blog: https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/
family.set <- family(cbc_isbm_model)
ilink.family.set<- family.set$linkinv
mod<-cbc_isbm_model
ndata<-Season_cbc_isbm_no_nas %>% group_by(status, finescale_fishery_old, finescale_fishery, season) %>% tidyr::expand(historic_summer = seq(0, max(historic_summer), length=100))
## add the fitted values by predicting from the model for the new data
ndata<- add_column(ndata, fit = predict(mod, newdata = ndata, type = 'response'))
ndata<- bind_cols(ndata, setNames(as_tibble(predict(mod, ndata, se.fit = TRUE)[1:2]),
c('fit_link','se_link')))
ndata <- mutate(ndata,
fit_resp = ilink.family.set(fit_link),
right_upr = ilink.family.set(fit_link + (2 * se_link)),
right_lwr = ilink.family.set(fit_link - (2 * se_link)))